<%@ LANGUAGE="VBSCRIPT" %>
<% option explicit%>
<% Response.Expires=0 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
dim Node
Node=request("Node")
if isEmpty(Node) then Node="_P"

function Money(S)
dim s1, k, s0
if NOT isNULL(S) THEN 
	s0=replace(s," ","")
	k=Len(S0)-5
	if k=0 THEN S1="0."
	if k=-1 THEN S1="0.0"
	if k=-2 THEN S1="0.00"
	if k=-3 THEN S1="0.000"
	if k<=-4 THEN S1="0.0000"
	if k>0 THEN S1=Left(S0,k)& "." 
	s1=s1 & Right(S0,5)
	Money=Left(s1,Len(s1)-3)
else
	Money=NULL
end if
end function

%>
<html>
<head>
		<title>Table mepss</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<!--METADATA NAME="Microsoft ActiveX Data Objects 2.5 Library" TYPE="TypeLib" UUID="{00000205-0000-0010-8000-00AA006D2EA4}"-->
</head>

<body bgcolor="#FBF3BB" _onload="Cycle();" >
<%
	Dim cnn
	Dim ManColor,DColor,id0,id, MS, MS1, DS, DS1, SS, hr, NE, Color
	Dim connStr
	Dim R, cmdM, cmdD
	Set cnn=Server.CreateObject("ADODB.Connection")
	Set R=Server.CreateObject("ADODB.Recordset")
	Set cmdM=Server.CreateObject("ADODB.Command")
	Set cmdD=Server.CreateObject("ADODB.Command")
	connStr="Provider=SQLOLEDB.1;Persist Security Info=True;User ID=Test;Password=Test;Initial Catalog=SMS"&Node&";Data Source=(local)"
	cnn.open connStr
	Set cmdM.ActiveConnection = cnn
	cmdM.CommandType=adCmdStoredProc
	cmdM.CommandText = "sp_id_ManagerResult"
	CmdM.Parameters.Append CmdM.CreateParameter("@Manager_id", adBigInt, adParamInput)
	CmdM.Parameters.Append CmdM.CreateParameter("@Period", adVarChar, adParamInput,10)
	CmdM.Parameters.Append CmdM.CreateParameter("@NumberOK", adInteger, adParamOutput)
	CmdM.Parameters.Append CmdM.CreateParameter("@SummaOK", adBigInt, adParamOutput)
	CmdM.Parameters.Append CmdM.CreateParameter("@NumberERR", adInteger, adParamOutput)

	Set cmdD.ActiveConnection = cnn
	cmdD.CommandType=adCmdStoredProc
	cmdD.CommandText = "sp_id_DealerResult"
	CmdD.Parameters.Append CmdD.CreateParameter("@Dealer_id", adBigInt, adParamInput)
	CmdD.Parameters.Append CmdD.CreateParameter("@Period", adVarChar, adParamInput,10)
	CmdD.Parameters.Append CmdD.CreateParameter("@NumberOK", adInteger, adParamOutput)
	CmdD.Parameters.Append CmdD.CreateParameter("@SummaOK", adBigInt, adParamOutput)

	id0=" "
	R.open "select * from meps.dbo.[View_Managers] ", cnn,1,3,1
	
	%>
	<table border="1" width="98%" align="center" cellpadding=4>
	<tr align="center">
<th  align="center"><table  height="16"  width="16"><tr><td bgcolor="#FF0000" id="FC">&nbsp;</td></tr></table></th>
<th colspan=1 ><font size=+1>meps</font></th>
<th colspan=7 ><font size=+1>Managers</font></th>
<th colspan=8><font size=+1>Payments</font></th>
</tr>
<tr align="center">
<td  align="center" rowspan=2><font size=-1>id</font></td>
<td rowspan=2><font size=-1>Name</font></td>
<td  align="center" rowspan=2><font size=-1>id</font></td>
<td rowspan=2><font size=-1>Name</font></td>
<td rowspan=2><font size=-1>Phone</font></td>
<td rowspan=2><font size=-1>Enabled</font></td>
<td rowspan=2><font size=-1>Account</font></td>
<td rowspan=2><font size=-1>Summary</font></td>
<td rowspan=2><font size=-1>LastTime</font></td>
<td colspan=2><font size=-1>Today</font></td>
<td colspan=2><font size=-1>Yesterday</font></td>
<td colspan=2><font size=-1>This week</font></td>
<td colspan=2><font size=-1>This month</font></td>
</tr>
<tr align="center">
<td><font size=-1>OK</font></td>
<td><font size=-1>Err</font></td>
<td><font size=-1>OK</font></td>
<td><font size=-1>Err</font></td>
<td><font size=-1>OK</font></td>
<td><font size=-1>Err</font></td>
<td><font size=-1>OK</font></td>
<td><font size=-1>Err</font></td>
</tr>
	<%
	id0=0
	Do while (Not R.eof) ''''AND i<=12
	if R("Enabled")="N" THEN 
		DColor="#c0a0a0" 
		ManColor="#c0c0c0"
	ELSE 
		if R("ManagerEnabled")="N" THEN ManColor="#c0c0c0" ELSE ManColor="Black"
		DColor="#2020c0" 
	end if
	id=cint(R("ID"))
    %>
<%IF (id0 <> id) THEN
' ------------------------------ dealer ----------------------------------------
DS=R("Summary")
DS1=Money(DS)
%>
<tr align="center" style="color: <%=DColor%>">
<th ><font size=-1><%= R("ID") %></font></th>
<th><font size=-1><%=R("Name")   %></font></th>
<th colspan=2>&nbsp;</th>
<th><font size=-1><b><%= R("Phone")  %></b></font></th>
<th align=left><font size=-3  ><%= R("Enabled")%>&nbsp;</font></th>
<td><font size=-1><%= R("BankAndAccount")  %>&nbsp;</font></td>
<td><font size=-1><b><%= DS1  %>&nbsp;</b></font></td>
<td><font size=-1><%= R("LastTime")  %>&nbsp;</font></td>
<%
	CmdD("@Dealer_id") = R("id")
	CmdD("@Period")="Today"
	cmdD.execute
	SS=CmdD("@SummaOK")
	if NOT isNULL(SS) THEN hr="<hr width=90% >" ELSE hr=NULL
%>
<th><font size=-1><%= CmdD("@NumberOK")  %>&nbsp;<%=hr%><%= Money(SS)  %></font></th>
<th>&nbsp;</th>
<%
	CmdD("@Period")="Yesterday"
	cmdD.execute
	SS=CmdD("@SummaOK")
	if NOT isNULL(SS) THEN hr="<hr width=90% >" ELSE hr=NULL
%>
<th><font size=-1><%= CmdD("@NumberOK")  %>&nbsp;<%=hr%><%= Money(SS)  %></font></th>
<th>&nbsp;</th>
<%
	CmdD("@Period")="Week"
	cmdD.execute
	SS=CmdD("@SummaOK")
	if NOT isNULL(SS) THEN hr="<hr width=90% >" ELSE hr=NULL
%>
<th><font size=-1><%= CmdD("@NumberOK")  %>&nbsp;<%=hr%><%= Money(SS)  %></font></th>
<th>&nbsp;</th>
<%
	CmdD("@Period")="Month"
	cmdD.execute
	SS=CmdD("@SummaOK")
	if NOT isNULL(SS) THEN hr="<hr width=90% >" ELSE hr=NULL
%>
<th><font size=-1><%= CmdD("@NumberOK")  %>&nbsp;<%=hr%><%= Money(SS)  %></font></th>
<th>&nbsp;</th>
</tr>
<%
' ------------------------------      ----------------------------------------
END IF
MS=R("ManSummary")
MS1=Money(MS)
%>
<tr align="center" style="color: <%=ManColor%>">
<td colspan=2>&nbsp;</td>
<td><font size=-2><%= R("Manager_ID") %>&nbsp;</font></td>
<td><font size=-2>
<%=R("ManagerName")   %>&nbsp;
</font></td>
<td><font size=-1><b><%= R("ManagerPhone")  %>&nbsp;</b></font></td>
<td align=left><font size=-3  ><%= R("ManagerEnabled")%>&nbsp;</font></td>
<td><font size=-1><%= R("ManAccount")  %>&nbsp;</font></td>
<td><font size=-1><b><%= MS1 %>&nbsp;</b></font></td>
<td><font size=-1><%= R("ManLastTime")  %>&nbsp;</font></td>
<%
	CmdM("@Manager_id") = R("Manager_id")
	CmdM("@Period")="Today"
	cmdM.execute
	SS=CmdM("@SummaOK")
	if NOT isNULL(SS) THEN hr="<hr width=90% >" ELSE hr=NULL
	NE=CmdM("@NumberERR")
	if NE=0 THEN color="Black" ELSE color="Red"
	
%>
<td><font size=-1><%= CmdM("@NumberOK")  %>&nbsp;<%=hr%><%= Money(SS)  %></font></td>
<td><font size=-1 color=<%=Color%> ><%= NE  %>&nbsp;</font></td>
<%
	CmdM("@Period")="Yesterday"
	cmdM.execute
	SS=CmdM("@SummaOK")
	if NOT isNULL(SS) THEN hr="<hr width=90% >" ELSE hr=NULL
	NE=CmdM("@NumberERR")
	if NE=0 THEN color="Black" ELSE color="Red"
%>
<td><font size=-1><%= CmdM("@NumberOK")  %>&nbsp;<%=hr%><%= Money(SS)  %></font></td>
<td><font size=-1 color=<%=Color%> ><%= NE  %>&nbsp;</font></td>
<%
	CmdM("@Period")="Week"
	cmdM.execute
	SS=CmdM("@SummaOK")
	if NOT isNULL(SS) THEN hr="<hr width=90% >" ELSE hr=NULL
	NE=CmdM("@NumberERR")
	if NE=0 THEN color="Black" ELSE color="Red"
%>
<td><font size=-1><%= CmdM("@NumberOK")  %>&nbsp;<%=hr%><%= Money(SS)  %></font></td>
<td><font size=-1 color=<%=Color%> ><%= NE  %>&nbsp;</font></td>
<%
	CmdM("@Period")="Month"
	cmdM.execute
	SS=CmdM("@SummaOK")
	if NOT isNULL(SS) THEN hr="<hr width=90% >" ELSE hr=NULL
	NE=CmdM("@NumberERR")
	if NE=0 THEN color="Black" ELSE color="Red"
%>
<td><font size=-1><%= CmdM("@NumberOK")  %>&nbsp;<%=hr%><%= Money(SS)  %></font></td>
<td><font size=-1 color=<%=Color%> ><%= NE  %>&nbsp;</font></td>
</tr>
<%
	id0=id
	R.MoveNext
	Loop 
	%>
	</table>
		<%
	cnn.Close
	set R=nothing
	set cnn=nothing
	set cmdM=nothing
	set cmdD=nothing
%>
</font>
</body>
</html>
